<template>
    <BasicForm @register="registerForm" @submit="handleSubmit"/>    
    <div class="text-center">
        <a-button type="primary" @click="handleSubmit">保存</a-button>
    </div>
</template>
<script lang="ts" setup>
import { BasicForm, useForm } from '@/components/Form/index';
const emit = defineEmits(['success', 'register', 'submit']);

const [
registerForm,
{ getFieldsValue, setFieldsValue, validate },
] = useForm({
    labelWidth: 200,
    schemas: [
        {
            component: 'Input',
            field: 'billAddress',
            label: '发票领取地址',
            required: true,
            
        },
        {
            component: 'InputNumber',
            field: 'openInvoiceAmount',
            label: '开票最小金额',
            required: true,
        },
    ],
    showActionButtonGroup: false,
    baseColProps: { span: 24 },
});
const getData = async () => {
    return await validate();
}
const setData = (data: any) => {
    setFieldsValue(data);
}
const handleSubmit = async () => {
    const data = await getData();
    if (data) {
        emit('submit', data);
    }
}
defineExpose({
    getData,
    setData
})
</script>
